package com.example.screenshot_service

import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.embedding.engine.plugins.activity.ActivityAware
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding

/**
 * 截图插件类，注册到Flutter引擎
 */
class ScreenshotPlugin : FlutterPlugin, ActivityAware {
    private lateinit var channel: ScreenshotMethodChannel

    override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {
        channel = ScreenshotMethodChannel()
        channel.onAttachedToEngine(binding)
    }

    override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
        channel.onDetachedFromEngine(binding)
    }

    override fun onAttachedToActivity(binding: ActivityPluginBinding) {
        channel.onAttachedToActivity(binding)
    }

    override fun onDetachedFromActivityForConfigChanges() {
        channel.onDetachedFromActivityForConfigChanges()
    }

    override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) {
        channel.onReattachedToActivityForConfigChanges(binding)
    }

    override fun onDetachedFromActivity() {
        channel.onDetachedFromActivity()
    }
} 